﻿using System;

namespace SegmentTree
{
    class Program
    {
        static void Main(string[] args)
        {


            var nums = new int[] { -2, 0, 3, -5, 2, -1 };


            SegmentTree<int> segTree = new SegmentTree<int>(nums, new Add<int>());
            Console.WriteLine(segTree);
            segTree.set(0, 100);
            Console.WriteLine(segTree.query(0,2));
        }
    }

    public class Add<E> : Merger<E> where E : struct
    {
        public E merge(E a, E b)
        {
            dynamic v1 = a;
            dynamic v2 = b;
            return (E)(v1 + v2);
        }
    }
}
